import {createI18n} from 'vue-i18n'

import messages from '@intlify/unplugin-vue-i18n/messages'
import { type App } from 'vue';

export const locale = ref(navigator.language.slice(0,2))

const defaultLocale = messages?.hasOwnProperty(navigator.language)
  ? navigator.language
  : navigator.language.slice(0, 2);


export const i18n = createI18n({legacy: false, messages, locale: defaultLocale, fallbackLocale: 'zh'})

export const install = (app: App) => {
    console.log('install i18n')
    app.use(i18n)
}